<!--
TODO: fix isValid to check for post vars properly
-->
<?php
require_once "header.php"; 
 
//menu
require_once "menu.php";
 
if (isset($_POST['adding'])) {
	// perform validation
	if (isValid()) {
		$name = "'".$_POST['hairstylist']."'";
		if (isset($_POST['salon']) && trim($_POST['salon']) != "") {
			$salon = "'".$_POST['salon']."'";
		} else {
			$salon = "NULL";
		}
		if (isset($_POST['telephone']) && trim($_POST['telephone']) != "") {
			$telephone = "'".$_POST['telephone']."'";
		} else {
			$telephone = "NULL";
		}
		$countryId = $_POST['country'];
		$regionId = $_POST['region'];
		$cityId = $_POST['city'];
		$sql = "INSERT INTO Stylists (Name, Salon, Telephone, CityID, RegionID, CountryID) VALUES (".$name.",".$salon.",".$telephone.",".$cityId.",".$regionId.",".$countryId.")";
		$rs = mysql_query($sql);
		//TODO: redirect to this hairdresser's page...
		echo "Thank you.  Go to hairdresser.";
	} else {
		echo "Please fill all of the required fields. ";
		echo "<a href='".$PHP_SELF."'>Try again.</a> ";
	}
} else {
	include "addhairstylist.include.php";
}

// more content
require_once "footer.php";
?>

<?php
function isValid () {
	return true;
}
?>